<?php
namespace app\api\controller;

use app\common\business\Category as categoryBusi;
use app\common\lib\Show;
// 分类API
class Category extends ApiBase
{
	public function index(){
		
		//获取分类
		$categorys = (new categoryBusi())->getAllNormalCategorys();
		$result = \app\common\lib\Arr::getTree($categorys);
		//halt($categorys);
		return show(config('status.success'),'ok',$result);
	}

	// 商品列表页面中 按栏目检索
	public function search(){
		$result = [
			"name" => "一级分类",
			"focus_ids" => [1,11],
			"list" => [
				[
					["id" => 1,"name" => "二级分类1"],
					["id" => 2,"name" => "二级分类2"],
					["id" => 3,"name" => "二级分类3"],
					["id" => 4,"name" => "二级分类4"],
					["id" => 5,"name" => "二级分类5"],
				],
				[
					["id" => 11,"name" => "三级分类1"],
					["id" => 12,"name" => "三级分类2"],
					["id" => 13,"name" => "三级分类3"],
					["id" => 14,"name" => "三级分类4"],
					["id" => 15,"name" => "三级分类5"],
				],
			],
		];

		return Show::success($result);
	}

	// 获取子分类 category/sub/1
	public function sub(){
		$result = [
			["id" => 21,"name" => "点2到3分类1"],
			["id" => 22,"name" => "点2到3分类2"],
			["id" => 23,"name" => "点2到3分类3"],
			["id" => 24,"name" => "点2到3分类4"],
			["id" => 25,"name" => "点2到3分类5"],
		];

		return Show::success($result);
	}
}